/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package MeshlessShapeFunctions;

/**
 *
 * @author mark
 */
public class JQuartic implements IKernelFunction{

    public double evaluateNorm(double x, double y) {
        double xx = Math.sqrt(x*x + y*y);

        if( xx > 1.0 ){
            return 0.0;
        }else{
            return 2.0/3.0 - 9.0/32.0*xx*xx + 19.0/192.0*xx*xx*xx -5.0/512.0*xx*xx*xx*xx;
        }
    }

    public double evaluateSque(double x, double y) {
        return evaluateNorm(x, 0)*evaluateNorm(0, y);
    }

    public double evaluatePrimeNormX(double x, double y) {
        double xx = Math.sqrt(x*x + y*y);
        if( xx > 1.0 ){
            return 0.0;
        }else{
            return - 18.0/32.0 * xx + 57.0/192.0 * xx * xx -20.0/512.0 * xx * xx * xx;
        }
    }

    public double evaluatePrimeNormY(double x, double y) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public double evaluatePrimeSqueX(double x, double y) {
        return evaluatePrimeNormX(x, 0)*evaluatePrimeNormX(0, y);
    }

    public double evaluatePrimeSqueY(double x, double y) {
        return evaluatePrimeNormY(x, 0)*evaluatePrimeNormY(0, y);
    }

    public double evaluate(double x) {
        if( Math.abs(x) > 1.0 ){
            return 0.0;
        }else{
            return 2.0/3.0 - 9.0/32.0*x*x + 19.0/192.0*x*x*x -5.0/512.0*x*x*x*x;
        }
    }

    public double evaluateDerivaty(double d) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

	@Override
	public double evaluateSecondDerivaty(double d) {
		// TODO Auto-generated method stub
		return 0;
	}
}
